package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqReturnTransferFeeCollect;
import com.ruoyi.hqfinance.domain.HqReturnTransferFeeDetail;
import com.ruoyi.hqfinance.domain.vo.HqReturnTransferFeeCollectVo;
import com.ruoyi.hqfinance.domain.vo.HqReturnTransferFeeDetailVo;
import com.ruoyi.hqfinance.mapper.HqReturnTransferFeeCollectMapper;
import com.ruoyi.hqfinance.mapper.HqReturnTransferFeeDetailMapper;
import com.ruoyi.hqfinance.service.HqReturnTransferFeeDetailService;
import com.ruoyi.logistic.domain.PageDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqReturnTransferFeeDetailServiceImpl implements HqReturnTransferFeeDetailService {
    @Autowired
    private HqReturnTransferFeeDetailMapper hqReturnTransferFeeDetailMapper;
    @Autowired
    private HqReturnTransferFeeCollectMapper hqReturnTransferFeeCollectMapper;
    @Override
    public List<HqReturnTransferFeeDetail> selectAll(PageDate pageDate) {
        PageHelper.startPage(pageDate);
        return hqReturnTransferFeeDetailMapper.selectAll();
    }

    @Override
    public Boolean insert(HqReturnTransferFeeDetail hqReturnTransferFeeDetail) {
        return hqReturnTransferFeeDetailMapper.insert(hqReturnTransferFeeDetail);
    }

    @Override
    public Boolean update(HqReturnTransferFeeDetail hqReturnTransferFeeDetail) {
        return hqReturnTransferFeeDetailMapper.update(hqReturnTransferFeeDetail);
    }

    @Override
    public Boolean deleteById(Integer id) {
        return hqReturnTransferFeeDetailMapper.deleteById(id);
    }

    @Override
    public List<HqReturnTransferFeeDetail> search(HqReturnTransferFeeDetailVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return hqReturnTransferFeeDetailMapper.search(vo);
    }

    @Override
    public List<HqReturnTransferFeeCollect> collect(HqReturnTransferFeeCollectVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqReturnTransferFeeCollect> collects =  hqReturnTransferFeeCollectMapper.collect(vo);
        assert collects != null;
        for (HqReturnTransferFeeCollect hqReturnTransferFeeCollect : collects){
            if (vo.getTimeType() == 2){
                hqReturnTransferFeeCollect.setSettleDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return collects;
    }
}
